GtkInspector: Fix Build on Windows
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 16 May 2014 10:02:00 +0000 (18:02 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 16 May 2014 15:50:20 +0000 (23:50 +0800)
Update visual.c to use Windows themes rather than the stock Raleigh theme,
and avoid hardcoding data paths for Windows (and Mac).  As the dlfcn.h
functions are only used when Python is enabled, move its inclusion there[*].

Also ensure that variables are declared on the top of the block.

[*] Python support Windows needs to be investigated, as POSIX signal
    handling is used there.

https://bugzilla.gnome.org/show_bug.cgi?id=730236

gtk/inspector/classes-list.c
gtk/inspector/python-hooks.c
gtk/inspector/visual.c

index c4f8d92cda21b3e2c49dbea4d6952d041ba4d192..a5f716dc8b81c77cfa5ba9b2b9a61c9778facfba 100644 (file)
@@ -138,10 +138,11 @@ add_clicked (GtkButton               *button,
       if (*name && !g_hash_table_contains (context, name))
         {
           GtkTreeIter tree_iter;
+          GtkInspectorClassesListByContext *c;
 
           gtk_style_context_add_class (cl->priv->context, name);
 
-          GtkInspectorClassesListByContext *c = g_new0 (GtkInspectorClassesListByContext, 1);
+          c = g_new0 (GtkInspectorClassesListByContext, 1);
           c->enabled = TRUE;
           c->style = PANGO_STYLE_ITALIC;
           g_hash_table_insert (context, (gpointer)g_strdup (name), c);
index 74d74fa99188dfed103950b3dd94b87b56799873..b8253d259d6b6d67d952d0b41e880168b534cdc3 100644 (file)
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include <dlfcn.h>
 #include <signal.h>
 
 #ifdef ENABLE_PYTHON
+# include <dlfcn.h>
 # include <Python.h>
 # include <pygobject.h>
 #endif
index e16cb9a5bb6e516adc49c331aff7337c9d64acc8..0130c390efd2ffddab933dbaa3a50e2a4b2c6a23 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "visual.h"
 
+#include "gtkprivate.h"
+
 struct _GtkInspectorVisualPrivate
 {
   GtkWidget *direction_combo;
@@ -158,6 +160,20 @@ fill_gtk (const gchar *path,
     }
 }
 
+static gchar*
+get_data_path (const gchar *subdir)
+{
+  gchar *base_datadir, *full_datadir;
+#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
+  base_datadir = _gtk_get_datadir();
+#else
+  base_datadir = g_strdup (GTK_DATADIR);
+#endif
+  full_datadir = g_build_filename (base_datadir, subdir, NULL);
+  g_free (base_datadir);
+  return full_datadir;
+}
+
 static void
 init_theme (GtkInspectorVisual *vis)
 {
@@ -166,11 +182,19 @@ init_theme (GtkInspectorVisual *vis)
   gchar *theme, *current_theme, *path;
   gint i, pos;
   GSettings *settings;
+  gchar *themedir = get_data_path ("themes");
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+#ifdef G_OS_WIN32
+  g_hash_table_add (t, g_strdup ("gtk-win32"));
+#else
   g_hash_table_add (t, g_strdup ("Raleigh"));
+#endif
+
+  fill_gtk (themedir, t);
+
+  g_free (themedir);
 
-  fill_gtk (GTK_DATADIR "/themes", t);
   path = g_build_filename (g_get_user_data_dir (), "themes", NULL);
   fill_gtk (path, t);
   g_free (path);
@@ -244,10 +268,14 @@ init_icons (GtkInspectorVisual *vis)
   gchar *theme, *current_theme, *path;
   gint i, pos;
   GSettings *settings;
+  gchar *iconsdir = get_data_path ("icons");
 
   t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
-  fill_icons (GTK_DATADIR "/icons", t);
+  fill_icons (iconsdir, t);
+
+  g_free (iconsdir);
+
   path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
   fill_icons (path, t);
   g_free (path);